/******************************************************************************
**                 Proprietary and Confidential Information                  **
**                                                                           **
**                Copyright (c) 2010 Conexant Systems, Inc.                  **
**                                                                           **
**  This software contains proprietary and confidential material which is    **
**  the property of Conexant Systems, Inc.                                   **
**                                                                           **
******************************************************************************/
#ifndef _dc_gfx_api_h_
#define _dc_gfx_api_h_
/******************************************************************************
*  FILE FORMAT: <PUBLIC>
*      1. INCLUDES 
*      2. ENUMERATIONS 
*      3. DEFINES
*      4. STRUCTURES
*      5. GLOBALS
*      6. PUBLIC FUNCTION PROTOTYPES
******************************************************************************/
/******************************************************************************
*  1. INCLUDES
******************************************************************************/

/******************************************************************************
*  2. ENUMERATIONS
******************************************************************************/

typedef enum DC_VO_PIXEL_FORMAT_FIELD_TYPE
{
	PFF_TYPE_PRIMARY_MONO = 0,
	PFF_TYPE_PRIMARY_BLUE,
	PFF_TYPE_PRIMARY_GREEN,
	PFF_TYPE_PRIMARY_RED,
	PFF_TYPE_PRIMARY_INDIRECT,
	PFF_TYPE_OVERLAY_INDIRECT,
	PFF_TYPE_UNUSED,
	PFF_TYPE_COUNT,					// always last
} DC_VO_PIXEL_FORMAT_FIELD_TYPE;

typedef enum DC_GA_KEY_CONTROL
{
	DC_GA_KEY_CTRL_NONE = 0x00,
	DC_GA_KEY_CTRL_SRC = 0x04,
	DC_GA_KEY_CTRL_DST = 0x05,
	DC_GA_KEY_CTRL_SRC_NOT = 0x06,
	DC_GA_KEY_CTRL_DST_NOT = 0x07,
} DC_GA_KEY_CONTROL;

typedef enum DC_GA_PIXEL_FORMAT
{
	DC_GA_PIXEL_FORMAT_PSEUDO8 = 0x00,
	DC_GA_PIXEL_FORMAT_1555 = 0x01,
	DC_GA_PIXEL_FORMAT_8888 = 0x02,
	DC_GA_PIXEL_FORMAT_565 = 0x03,
} DC_GA_PIXEL_FORMAT;

typedef enum DC_GA_OPCODE
{
	DC_GA_OPCODE_NOOP			= 0x00,
	DC_GA_OPCODE_BITBLT			= 0x01,
	DC_GA_OPCODE_LINE			= 0x02,
	DC_GA_OPCODE_ELINE			= 0x03,
	DC_GA_OPCODE_PLINE			= 0x05,
} DC_GA_OPCODE;

typedef enum DC_GA_ROP
{
	DC_GA_ROP_CLEAR 			= 0x00,			// 0 (zero)
	DC_GA_ROP_NOR   			= 0x01,			// (NOT src) AND (NOT dst)
	DC_GA_ROP_AND_INVERTED 		= 0x02,			// (NOT src) AND (dst)
	DC_GA_ROP_COPY_INVERTED 	= 0x03,			// (NOT src)
	DC_GA_ROP_AND_REVERSE 		= 0x04,			// src AND (NOT dst)
	DC_GA_ROP_INVERT 			= 0x05,			// (NOT dst)
	DC_GA_ROP_XOR 				= 0x06,			// src XOR dst
	DC_GA_ROP_NAND 				= 0x07,			// (NOT src) OR (NOT dst)
	DC_GA_ROP_AND 				= 0x08,			// src AND dst
	DC_GA_ROP_EQUIV 			= 0x09,			// (NOT src) OR dst
	DC_GA_ROP_NOOP  			= 0x0A,			// dst
	DC_GA_ROP_OR_INVERTED 		= 0x0B,			// (NOT src) OR dst
	DC_GA_ROP_COPY 				= 0x0C,			// src
	DC_GA_ROP_OR_REVERSE 		= 0x0D,			// src OR (NOT dst)
	DC_GA_ROP_OR 				= 0x0E,			// src OR dst
	DC_GA_ROP_SET 				= 0x0F,			// 1 (one)
} DC_GA_ROP;

typedef enum DC_GA_STYLE
{
	DC_GA_CMD_STYLE_NONE = 0x00,
	DC_GA_CMD_STYLE_SOLID = 0x01,
	DC_GA_CMD_STYLE_TRANSPARENT = 0x02,
	DC_GA_CMD_STYLE_STIPPLE_PACK = 0x04,
	DC_GA_CMD_STYLE_STIPPLE = 0x08,
} DC_GA_STYLE;

typedef enum DC_GA_AREA_PATTERN
{
	DC_GA_CMD_AREA_PATTERN_OFF = 0x00,
	DC_GA_CMD_AREA_PATTERN_8x8 = 0x01,
	DC_GA_CMD_AREA_PATTERN_32x32 = 0x02,
} DC_GA_AREA_PATTERN;

typedef enum DC_GA_CLIP
{
	DC_GA_CMD_CLIP_NONE = 0x00,
	DC_GA_CMD_CLIP_DRAW_INSIDE = 0x02,
	DC_GA_CMD_CLIP_DRAW_OUTSIDE = 0x03,
} DC_GA_CLIP;

typedef enum DC_GA_HDF_SWAP
{
	DC_GA_CMD_HDF_BIT_SWAP = 0x01,
	DC_GA_CMD_HDF_BYTE_SWAP = 0x02,
	DC_GA_CMD_HDF_WORD_SWAP = 0x04,
} DC_GA_HDF_SWAP;

typedef enum DC_GA_ALPHA_OPERATION
{
	DC_GA_ALPHA_SRC_ZERO					= 0x00,			// (0,0,0,0)
	DC_GA_ALPHA_SRC_ONE 					= 0x01,			// (1,1,1,1)
	//DC_GA_ALPHA_SRC_DST_COLOR				= 0x02,			// (Ad,Rd,Gd,Bd)
	//DC_GA_ALPHA_SRC_ONE_MINUS_DST			= 0x03,			// (1,1,1,1) - (Ad,Rd,Gd,Bd)
	DC_GA_ALPHA_SRC_SRC_ALPHA				= 0x04,			// (As,As,As,As)
	DC_GA_ALPHA_SRC_ONE_MINUS_SRC_ALPHA		= 0x05,			// (1,1,1,1) - (As,As,As,As)
	DC_GA_ALPHA_SRC_DST_ALPHA				= 0x06,			// (Ad,Ad,Ad,Ad)
	DC_GA_ALPHA_SRC_ONE_MINUS_DST_ALPHA		= 0x07,			// (1,1,1,1) - (Ad,Ad,Ad,Ad)
	DC_GA_ALPHA_DST_ZERO					= 0x00,			// (0,0,0,0)
	DC_GA_ALPHA_DST_ONE 					= 0x10,			// (1,1,1,1)
	//DC_GA_ALPHA_DST_SRC_COLOR				= 0x20,			// (As,Rs,Gs,Bs)
	//DC_GA_ALPHA_DST_ONE_MINUS_SRC			= 0x30,			// (1,1,1,1) - (As,Rs,Gs,Bs)
	DC_GA_ALPHA_DST_SRC_ALPHA				= 0x40,			// (As,As,As,As)
	DC_GA_ALPHA_DST_ONE_MINUS_SRC_ALPHA		= 0x50,			// (1,1,1,1) - (As,As,As,As)
	DC_GA_ALPHA_DST_DST_ALPHA				= 0x60,			// (Ad,Ad,Ad,Ad)
	DC_GA_ALPHA_DST_ONE_MINUS_DST_ALPHA		= 0x70,			// (1,1,1,1) - (Ad,Ad,Ad,Ad)
} DC_GA_ALPHA_OPERATION;

typedef enum DC_GA_BITBLT_DIR
{
	DC_GA_BITBLT_DIR_LRTB 		= 0x00,
	DC_GA_BITBLT_DIR_LRBT 		= 0x01,
	DC_GA_BITBLT_DIR_RLTB 		= 0x02,
	DC_GA_BITBLT_DIR_RLBT 		= 0x03,
} DC_GA_BITBLT_DIR;

typedef enum DC_GA_DL_REG_ADDR
{
	DC_GA_INTP				= 0x0000,
	DC_GA_INTM				= 0x0004,
	DC_GA_FLOW				= 0x0008,
	DC_GA_BUSY				= 0x000C,
	DC_GA_XYW_AD			= 0x0010,
	DC_GA_DL_GLYPH_ORG		= 0x0018,
	DC_GA_BUF_CTRL			= 0x0020,
	DC_GA_DL_OFFSET			= 0x0024,
	DC_GA_DE_SORG			= 0x0028,
	DC_GA_DE_DORG			= 0x002C,
	DC_GA_DE_SPTCH			= 0x0040,
	DC_GA_DE_DPTCH			= 0x0044,
	DC_GA_CMD				= 0x0048,
	DC_GA_CMD_OPC			= 0x0050,
	DC_GA_CMD_ROP			= 0x0054,
	DC_GA_CMD_STYLE			= 0x0058,
	DC_GA_CMD_PATRN			= 0x005C,
	DC_GA_CMD_CLP			= 0x0060,
	DC_GA_CMD_HDF			= 0x0064,
	DC_GA_FORE				= 0x0068,
	DC_GA_BACK				= 0x006C,
	DC_GA_MASK				= 0x0070,
	DC_GA_DE_KEY			= 0x0074,
	DC_GA_LPAT				= 0x0078,
	DC_GA_PCTRL				= 0x007C,
	DC_GA_CLPTL				= 0x0080,
	DC_GA_CLPBR				= 0x0084,
	DC_GA_XY0				= 0x0088,
	DC_GA_XY1				= 0x008C,
	DC_GA_XY2				= 0x0090,
	DC_GA_XY3				= 0x0094,
	DC_GA_XY4				= 0x0098,
	DC_GA_DL_ADR			= 0x00F8,
	DC_GA_DL_CNTRL			= 0x00FC,
	DC_GA_AFREG				= 0x0128,
	DC_GA_ACNTRL			= 0x016C,
} DC_GA_DL_REG_ADDR;

typedef enum DC_GA_TRIANGLE_FLAGS
{
	DGTF_NO_FLAGS = 0x00000000,
	DGTF_NO_LEFT_MOST_PIXEL = 0x00000001,
	DGTF_NO_RIGHT_MOST_PIXEL = 0x00000002,
	DGTF_NO_TOP_MOST_LINE = 0x00000004,
	DGTF_NO_BOTTOM_MOST_LINE = 0x00000008,
} DC_GA_TRIANGLE_FLAGS;

/******************************************************************************
*  3. DEFINES
******************************************************************************/

#define DC_VO_MAX_PIXEL_FORMAT_FIELDS 5
#define DC_GFX_MAX_RESOLUTION 4096             // make a power of 2 for easy math, limit is 2^^15

typedef UINT8 DC_VO_PIXEL_FORMAT;

/******************************************************************************
*  4. STRUCTURES
******************************************************************************/

typedef struct DC_VO_PIXEL_FORMAT_FIELD_DESC
{
	DC_VO_PIXEL_FORMAT_FIELD_TYPE type;
	int offset;
	int width;
} DC_VO_PIXEL_FORMAT_FIELD_DESC;

typedef struct DC_VO_PIXEL_FORMAT_DESC
{
	int bits_per_pixel;
	int num_fields;
	DC_VO_PIXEL_FORMAT_FIELD_DESC field[DC_VO_MAX_PIXEL_FORMAT_FIELDS];
} DC_VO_PIXEL_FORMAT_DESC;

typedef struct DC_GA_COMPLETION_DESC
{
	boolean waitCompletion;
	void (*completionCallback)(UINT32 user_arg);		// This feature not implemented yet
	UINT32 user_arg;									// This feature not implemented yet
} DC_GA_COMPLETION_DESC;

typedef struct DC_GFX_POINT
{
	int x;
	int y;
} DC_GFX_POINT;

typedef struct DC_GFX_FLOAT_POINT
{
	float x;
	float y;
} DC_GFX_FLOAT_POINT;

typedef struct DC_GFX_RECTANGLE
{
	DC_GFX_POINT tl;
	DC_GFX_POINT br;
} DC_GFX_RECTANGLE;

typedef struct DC_GA_TRIANGLE_STATS
{
	UINT32 totalTime;				// in us
	UINT32 characterizeTime;		// in us
	UINT32 spanLineArrayTime;		// in us
	UINT32 displayListTime;			// in us
	UINT32 renderTime;				// in us
	DC_GFX_RECTANGLE boundingBox;
	UINT32 pixelCount;
} DC_GA_TRIANGLE_STATS;

/******************************************************************************
*  5. GLOBALS
******************************************************************************/

/******************************************************************************
*  6. PUBLIC FUNCTION PROTOTYPES
******************************************************************************/

UINT32 dc_vo_get_current_buffer(void);		// returns physical address
UINT32 dc_vo_get_current_stride(void);
void dc_vo_write_lut(int index,int count,UINT8 *lutValues); // lutValues length should be (3 * count)
void dc_vo_read_lut(int index,int count,UINT8 *lutValues);	// lutValues length should be (3 * count)
int dc_vo_get_lut_index_count(void);
int dc_vo_get_pixel_format_count(void);
DC_VO_PIXEL_FORMAT dc_vo_get_current_pixel_format(void);
void dc_vo_get_pixel_format_desc(DC_VO_PIXEL_FORMAT pf,DC_VO_PIXEL_FORMAT_DESC *p_pfd);
void dc_vo_set_pixel_format(DC_VO_PIXEL_FORMAT pf,UINT32 physicalAddress,UINT32 stride);
void dc_vo_wait_end_of_frame(void);
void dc_vo_flip_buffer(UINT32 physicalAddress,boolean waitForFlip);
void dc_vo_flip_buffer_and_stride(UINT32 physicalAddress,UINT32 stride);
boolean dc_vop_overlay_is_enabled(void);
void dc_vop_overlay_enable(void);
void dc_vop_overlay_disable(void);
UINT32 dc_vop_get_current_overlay_buffer(void);		// returns physical address
UINT32 dc_vop_get_current_overlay_stride(void);
void dc_vop_flip_overlay_buffer(UINT32 physicalAddress,boolean waitForFlip);
void dc_vop_flip_overlay_buffer_and_stride(UINT32 physicalAddress,UINT32 stride);
//N.B., dc_gfx_blit is faster than dc_gfx_mi_blit for line widths less than 512 bytes (width * bytes_per_pixel)
// For dc_gfx_blit, src and dst must be virtual addresses
void dc_gfx_blit(UINT32 src,UINT32 dst,UINT32 srcStride,UINT32 dstStride,
										UINT32 width,UINT32 height,int bytes_per_pixel);
//N.B., dc_gfx_mi_blit is faster than dc_gfx_blit for line widths greater than 512 bytes (width * bytes_per_pixel)
// For dc_gfx_mi_blit, src and dst must be virtual addresses
void dc_gfx_mi_blit(UINT32 src,UINT32 dst,UINT32 srcStride,UINT32 dstStride,
										UINT32 width,UINT32 height,int bytes_per_pixel);
void dc_gfx_draw_solid_16bpp_line(UINT16 *frameAddress,UINT32 pixelStride,UINT16 color,int x0,int y0,int x1,int y1);
void dc_gfx_copy_16bpp_line(UINT16 *src,UINT16 *dst,UINT32 pixelStride,int x0,int y0,int x1,int y1);
void dc_gfx_draw_solid_32bpp_line(UINT32 *frameAddress,UINT32 pixelStride,UINT32 color,int x0,int y0,int x1,int y1);
void dc_gfx_copy_32bpp_line(UINT32 *src,UINT32 *dst,UINT32 pixelStride,int x0,int y0,int x1,int y1);
// returns FALSE if intersection is NULL, otherwise TRUE and rectCommon is valid
boolean dc_gfx_rectangle_intersection(DC_GFX_RECTANGLE *rect1,DC_GFX_RECTANGLE *rect2,DC_GFX_RECTANGLE *rectCommon);
// For dc_gfx_ga_blit, src and dst must be physical addresses and 16-byte aligned.  srcStride and dstStride
// must also be 16-byte aligned.
void dc_gfx_ga_blit(UINT32 src,UINT32 dst,UINT32 srcStride,UINT32 dstStride,
                                          UINT32 width,UINT32 height,int bytes_per_pixel);
void dc_ga_soft_reset(void);
void dc_ga_clean_regs(boolean cleanCache);
boolean dc_ga_pipe_not_full(void);
void dc_ga_wait_pipe_not_full(void);
boolean dc_ga_de_not_busy(void);
void dc_ga_wait_de_not_busy(void);
boolean dc_ga_mc_not_busy(void);
void dc_ga_wait_mc_not_busy(void);
boolean dc_ga_previous_command_not_busy(void);
void dc_ga_wait_previous_command_not_busy(void);
boolean dc_ga_de_mc_not_busy(void);
void dc_ga_wait_de_mc_not_busy(void);
boolean dc_ga_dlp_done(void);
void dc_ga_wait_dlp_done(void);
void dc_ga_stop_dlp(void);
// For dc_set_source, physical_address and stride must be 16-byte aligned
void dc_ga_set_source(UINT32 physical_address,UINT32 stride);
// For dc_set_destination, physical_address and stride must be 16-byte aligned
void dc_ga_set_destination(UINT32 physical_address,UINT32 stride);
void dc_ga_set_color(UINT32 foreground,UINT32 background);
void dc_ga_set_color_key(UINT32 colorKey);
void dc_ga_set_plane_mask(UINT32 planeMask);
void dc_ga_set_clip_rectangle(DC_GFX_RECTANGLE *rect);
// Use for Display List Format 0 3-register instruction setup
UINT32 dc_ga_format_clip_rectangle_tl(DC_GFX_RECTANGLE *rect);
// Use for Display List Format 0 3-register instruction setup
UINT32 dc_ga_format_clip_rectangle_br(DC_GFX_RECTANGLE *rect);
void dc_ga_set_line_pattern(UINT32 pattern);
void dc_ga_set_line_pattern_control(UINT8 length,UINT8 scaleFactor,UINT8 patternOffset,UINT8 initialOffset);
// Use for Display List Format 0 3-register instruction setup
UINT32 dc_ga_format_line_pattern_control(UINT8 length,UINT8 scaleFactor,UINT8 patternOffset,UINT8 initialOffset);
void dc_ga_set_alpha_factor(UINT8 srcFactor,UINT8 dstFactor);
// Use for Display List Format 0 3-register instruction setup
UINT32 dc_ga_format_alpha_factor(UINT8 srcFactor,UINT8 dstFactor);
void dc_ga_set_alpha_control(DC_GA_ALPHA_OPERATION srcOp,DC_GA_ALPHA_OPERATION dstOp,boolean enable);
// Use for Display List Format 0 3-register instruction setup
UINT32 dc_ga_format_alpha_control(DC_GA_ALPHA_OPERATION srcOp,DC_GA_ALPHA_OPERATION dstOp,boolean enable);
void dc_ga_set_cmd_opcode(DC_GA_OPCODE opcode);
void dc_ga_set_cmd_rop(DC_GA_ROP rop);
void dc_ga_set_cmd_style(DC_GA_STYLE style);
void dc_ga_set_cmd_pattern(DC_GA_AREA_PATTERN areaPattern,boolean noLastPixel,boolean resetPointers);
// Use for Display List Format 0 3-register instruction setup
UINT32 dc_ga_format_cmd_pattern(DC_GA_AREA_PATTERN areaPattern,boolean noLastPixel,boolean resetPointers);
void dc_ga_set_cmd_clip(DC_GA_CLIP clip,boolean stopOnBoundary);
// Use for Display List Format 0 3-register instruction setup
UINT32 dc_ga_format_cmd_clip(DC_GA_CLIP clip,boolean stopOnBoundary);
void dc_ga_set_cmd_swap(UINT32 swap);
void dc_ga_set_buffer_control(DC_GA_KEY_CONTROL keyCtrl,DC_GA_PIXEL_FORMAT pixelFormat,
							  boolean readFromCache,boolean originXY,boolean fogTables,boolean cacheReady);
// Use for Display List Format 0 3-register instruction setup
UINT32 dc_ga_format_buffer_control(DC_GA_KEY_CONTROL keyCtrl,DC_GA_PIXEL_FORMAT pixelFormat,
							  boolean readFromCache,boolean originXY,boolean fogTables,boolean cacheReady);
void dc_ga_noop(DC_GA_COMPLETION_DESC *pcd);
void dc_ga_bitblt(DC_GFX_POINT *src,DC_GFX_POINT *dst,UINT16 width,UINT16 height,
													DC_GA_BITBLT_DIR dir,DC_GA_COMPLETION_DESC *pcd);
void dc_ga_line(DC_GFX_POINT *start,DC_GFX_POINT *end,DC_GA_COMPLETION_DESC *pcd);
void dc_ga_eline(DC_GFX_POINT *start,DC_GFX_POINT *end,
				 int majorDelta,int minorDelta,DC_GA_COMPLETION_DESC *pcd);
void dc_ga_pline(DC_GFX_POINT *end,DC_GA_COMPLETION_DESC *pcd);
// buffer_address must be a physical address
// buffer_address and stride must be 16-byte aligned
void dc_ga_bitblt_solid(UINT32 buffer_address,UINT32 stride,DC_GFX_POINT *start,
						UINT16 width,UINT16 height,UINT32 color,int bytes_per_pixel,DC_GA_COMPLETION_DESC *pcd);
// buffer_address must be a physical address
// buffer_address and stride must be 16-byte aligned
void dc_ga_line_solid(UINT32 buffer_address,UINT32 stride,DC_GFX_POINT *start,DC_GFX_POINT *end,
						UINT32 color,int bytes_per_pixel,DC_GA_COMPLETION_DESC *pcd);
// dlStart must be 16-byte aligned.
// dlStart must be physical address.
void dc_ga_set_dl_start(UINT32 dlStart,boolean waitCacheFlush);
// dlEnd must be 16-byte aligned.
// dlEnd must be physical address.
void dc_ga_set_dl_end(UINT32 dlEnd,boolean isFormat1);
// dlGlyphOrg[31:28] are the top four bits of all glyph physical addresses
// in all active text tables.
// User must ensure that all active text table glyphs reside in the same
// 256 MB page.
void dc_ga_set_dl_glyph_org(UINT32 dlGlyphOrg);
// ttAddress must be 8-byte aligned.
// ttAddress must be virtual address.
// glyphAddress must be 16-byte aligned.
// glyphAddress must be physical address.
// Returns next available virtual address for a text table.
UINT32 dc_ga_setup_dl_text_table(UINT32 ttAddress,UINT32 glyphAddress,DC_GA_BITBLT_DIR dir,
													UINT16 width,UINT16 height,INT16 offsetX,INT16 offsetY);
// dlAddress must be 16-byte aligned.
// dlAddress must be virtual address.
// textTable<0,1> must be physical addresses.
// Returns next available virtual address in the display list.
UINT32 dc_ga_add_dl_fmt0_text(UINT32 dlAddress,boolean is2Characters,boolean waitVBI,
									 UINT32 textTable0,UINT32 textTable1,
									 DC_GFX_POINT *offset0,DC_GFX_POINT *offset1);
// dlAddress must be 16-byte aligned.
// dlAddress must be virtual address.
// Returns next available virtual address in the display list.
UINT32 dc_ga_add_dl_fmt0_reg1(UINT32 dlAddress,boolean waitVBI,
						      DC_GA_DL_REG_ADDR reg1Address,UINT32 reg1Data);
// dlAddress must be 16-byte aligned.
// dlAddress must be virtual address.
// Returns next available virtual address in the display list.
UINT32 dc_ga_add_dl_fmt0_reg2(UINT32 dlAddress,boolean waitVBI,
						      DC_GA_DL_REG_ADDR reg1Address,UINT32 reg1Data,
						      DC_GA_DL_REG_ADDR reg2Address,UINT32 reg2Data);
// dlAddress must be 16-byte aligned.
// dlAddress must be virtual address.
// Returns next available virtual address in the display list.
UINT32 dc_ga_add_dl_fmt0_reg3(UINT32 dlAddress,boolean waitVBI,
						      DC_GA_DL_REG_ADDR reg1Address,UINT32 reg1Data,
						      DC_GA_DL_REG_ADDR reg2Address,UINT32 reg2Data,
						      DC_GA_DL_REG_ADDR reg3Address,UINT32 reg3Data);
// dlAddress must be 16-byte aligned.
// dlAddress must be virtual address.
// Returns next available virtual address in the display list.
UINT32 dc_ga_add_dl_fmt1_reg4(UINT32 dlAddress,
							  UINT32 XY0Data,
							  UINT32 XY1Data,
							  UINT32 XY2Data,
							  UINT32 XY3Data);
// vertex<0,1,2> represent triangle in destination buffer.
// The source buffer triangle must be congruent to vertex<0,1,2>
// The source buffer triangle vertices are equal to (vertex<0,1,2> + source_offset).
// x and y members of vertex<0,1,2> must be less than DC_GFX_MAX_RESOLUTION.
// span_line_desc_array_address must be virtual address and must encompass enough
//   memory to satisfy (8 bytes x triangle y-span height).
// display_list_address_<v,p> must be 16-byte aligned.
// display_list_address_p must be physical address.
// display_list_address_v must be virtual address.
// display_list_address_<v,p> must encompass enough
//   memory to satisfy (16 bytes x (triangle y-span height + 1)).
// stats is optional, pass NULL pointer for no stats.
// direction is one of DC_GA_BITBLT_DIR_<LRTB,LRBT,RLTB,RLBT>
// flags is used to specify rendering options
void dc_ga_triangle(DC_GFX_POINT *vertex0,
					DC_GFX_POINT *vertex1,
					DC_GFX_POINT *vertex2,
					DC_GFX_POINT *source_offset,
					UINT32 span_line_desc_array_address,
					UINT32 display_list_address_p,
					UINT32 display_list_address_v,
					DC_GA_COMPLETION_DESC *pcd,
					DC_GA_TRIANGLE_STATS *stats,
					DC_GA_BITBLT_DIR direction,
					DC_GA_TRIANGLE_FLAGS flags);
// dc_ga_triangle_oglsp is a clone of the OpenGL Softpipe triangle render engine,
// optimized for 2D triangles.  The rendered triangles are "top left" by definition --
// this means that bottom span line and right-most pixels of each span line are 
// not rendered, in order to seamlessly mesh with triangles that share an edge.
// Parts of this function and its sub-functions were ported from the Mesa3d Gallium Softpipe
// triangle render engine, found in SVN at:
// 		package/mesa3d_gallium_fbdev/directfb_extras/src/gallium/drivers/softpipe/sp_setup.c
// N.B., this engine will not render points or lines -- all three vertices must be unique and
// not collinear.
//
// vertex<0,1,2> represent triangle in destination buffer.
// The source buffer triangle must be congruent to vertex<0,1,2>
// The source buffer triangle vertices are equal to (vertex<0,1,2> + source_offset).
// x and y members of vertex<0,1,2> must be less than DC_GFX_MAX_RESOLUTION.
// N.B., vertex<0,1,2> and source_offset are float, not int.
// span_line_desc_array_address must be virtual address and must encompass enough
//   memory to satisfy (8 bytes x triangle y-span height).
// display_list_address_<v,p> must be 16-byte aligned.
// display_list_address_p must be physical address.
// display_list_address_v must be virtual address.
// display_list_address_<v,p> must encompass enough
//   memory to satisfy (16 bytes x (triangle y-span height + 1)).
// stats is optional, pass NULL pointer for no stats.
// direction is one of DC_GA_BITBLT_DIR_<LRTB,LRBT,RLTB,RLBT>
void dc_ga_triangle_oglsp(DC_GFX_FLOAT_POINT *vertex0,
					      DC_GFX_FLOAT_POINT *vertex1,
					      DC_GFX_FLOAT_POINT *vertex2,
						  DC_GFX_FLOAT_POINT *source_offset,
						  UINT32 span_line_desc_array_address,
						  UINT32 display_list_address_p,
						  UINT32 display_list_address_v,
						  DC_GA_COMPLETION_DESC *pcd,
						  DC_GA_TRIANGLE_STATS *stats,
						  DC_GA_BITBLT_DIR direction);
#endif

